package com.fastloan.mgt.application.base.enums;

import com.fastloan.utils.enumutil.SelectEnum;

/**
 * 进件状态
 *
 * @author yanwe
 *         createTime 2017-11-2017/11/9 10:46
 */
public enum ApplicationStatusEnum implements SelectEnum {

    WAIT_SURVEY(1, "待调查"),
    MODEL_REJECT(2, "模型拒绝"),
    WAIT_SIGNED(3, "待签约"),
    IS_SIGNED(4, "已签约"),
    SIGNED_REJECT(5, "银行签约拒绝"),
    WAIT_PHONE_APPROVE(6, "待电核"),
    PHONE_APPROVE_REJECT(7, "电核拒绝"),
    WAIT_AFFIRM(8, "客户未签约"),
    CUSTOMER_REJECT_SIGNED(9, "客户拒绝签约"),
    FINISH(10, "还款完成"),
    APP_APPROVE(11, "审批中"),
    APP_APPROVE_REJECT(12, "审批拒绝"),
    MODEL_EVALUATE_ING(13, "模型评估中"),
    APP_LENDING(14, "放款中"),
    BAIDU_MODEL(15, "百度评估中"),
    BAIDU_MODEL_REJECT(16, "百度拒绝"),
    PERSON_BANK_VERIFY(17, "人行征信中"),
    TOBACCOL_VERIFY(18,"烟草证查询中"),
    WAIT_CUSTOMER_SIGNED(19,"待客户自行签约"),
    LOAN_REJECT(20,"放款审核拒绝"),
    LOAN_FAIL(21,"放款失败"),
    WAIT_REPAYMENT(22,"待还款"),
    PRELIMINARY_CREDIT(23,"预授信待审批"),
    PRELIMINARY_CREDIT_PASS(24,"预授信审批通过"),
    PRELIMINARY_CREDIT_NO_PASS(25,"预授信审批拒绝"),
    ORDER_CANCELLATION(26,"客户取消订单"),
    OVERDUE(27,"逾期中")
    ;

    private Integer type;

    private String typeName;

    ApplicationStatusEnum(Integer type, String typeName) {
        this.type = type;
        this.typeName = typeName;
    }

    @Override
    public String getTypeName() {
        return typeName;
    }

    @Override
    public Integer getType() {
        return type;
    }

    public static ApplicationStatusEnum getByType(Integer type) {
        switch (type) {
            case 1:
                return WAIT_SURVEY;
            case 2:
                return MODEL_REJECT;
            case 3:
                return WAIT_SIGNED;
            case 4:
                return IS_SIGNED;
            case 5:
                return SIGNED_REJECT;
            case 6:
                return WAIT_PHONE_APPROVE;
            case 7:
                return PHONE_APPROVE_REJECT;
            case 8:
                return WAIT_AFFIRM;
            case 9:
                return CUSTOMER_REJECT_SIGNED;
            case 10:
                return FINISH;
            case 11:
                return APP_APPROVE;
            case 12:
                return APP_APPROVE_REJECT;
            case 13:
                return MODEL_EVALUATE_ING;
            case 14:
                return APP_LENDING;
            case 15:
                return BAIDU_MODEL;
            case 16:
                return BAIDU_MODEL_REJECT;
            case 17:
                return PERSON_BANK_VERIFY;
            case 18:
                return TOBACCOL_VERIFY;
            case 19:
                return WAIT_CUSTOMER_SIGNED;
            case 20:
                return LOAN_REJECT;
            case 21:
                return LOAN_FAIL;
            case 22:
                return WAIT_REPAYMENT;
            case 23:
                return PRELIMINARY_CREDIT;
            case 24:
                return PRELIMINARY_CREDIT_PASS;
            case 25:
                return PRELIMINARY_CREDIT_NO_PASS;
            case 26:
                return ORDER_CANCELLATION;
            default:
                throw new IllegalArgumentException("未知的进件状态:" + type);
        }
    }


    public String toString() {
        return "{\"code\":" + jsonStr(type) + ",\"name\":" + jsonStr(typeName) + "}";
    }


    public String jsonStr(Object param) {
        if (param instanceof String) {
            return "\"" + param + "\"";
        } else {
            return param.toString();
        }
    }
}
